<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 300px;
            height: 300px;
            background-color: darkred;
            border: 1px solid darkblue;
        }
    </style>
</head>
<body>
    <div class="div1"></div>
    <script>
        var oDiv = document.querySelector(".div1");
        function getFinalStyle(element, attr){
            if(window.getComputedStyle){
                return getComputedStyle(element, null)[attr];
            }else{
                return element.currentStyle[attr];
            }
        }
        setInterval(function(){
            oDiv.style.width = parseInt(getFinalStyle(oDiv, "width")) - 1 + "px";
        }, 30);
    </script>
</body>
</html>